package cwb
import scala.collection.mutable.HashMap

object CWBCommands extends Commands[Command] {
  def commandLine = "Command: "
 
  /**
   * Prints all commands available to the workbench in alphabetical order, along with their
   * associated help information.
   */
  def showAvailableCommands() {
    // Iterate over the elements, sorted by the key alphabetically.
    commandMap.toList sortBy (_._1) foreach {
      case (_, command: Command) => println(command.name + ": " + command.helpShort)
    }
  }
  
  /** 
   * Prints the help information for the given command
   * @param command command of which help information is to be printed.
   */
  def printHelp(command: Command) {
    println(command.name + ": " + command.helpShort + "\n")
    // Add indentation to the detailed help for clarity.
    indentPrint(command.helpDetailed)
  }
}